### Loading in the Data and Libraries ###
setwd("")
data<-read.csv("02_Clean Racial Shift Full Replication Proprietary.csv")

library(dplyr)
library(car)
library(sandwich)
library(lmtest)
library(stargazer)
library(ggplot2)
library(RColorBrewer)
library(ggsignif)
library(lsr)
Nicole_theme<- ggplot2:: theme(plot.title=element_text(face="bold", size=22), 
                               axis.title.y=element_text(size=20), 
                               axis.text=element_text(size=14),
                               axis.title.x=element_text(size=20),
                               legend.title = element_text(size=20),
                               legend.text = element_text(size=14))


##### Regressions, Linear Hypothesis Tests, and Cohen's D Calculations for Each Dependent Variable #####

### Subjective Manipulation Checks ###
# Demographics
SMC_reg1<-lm(trends_closed_demog~ Treatment, data= data)
linearHypothesis(SMC_reg1, "TreatmentCultural Shift=TreatmentPolitical Shift")
linearHypothesis(SMC_reg1, "TreatmentCultural Shift=TreatmentPopulation Shift") 
linearHypothesis(SMC_reg1, "TreatmentPolitical Shift=TreatmentPopulation Shift") 
SMC_reg1<-coeftest(SMC_reg1, vcov= vcovHC, type= "HC1") 
SMC_reg1 # print for reported significance tests, full results reported in Appendix C


cohensD(trends_closed_demog ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(trends_closed_demog ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(trends_closed_demog ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))
cohensD(trends_closed_demog ~ Treatment, 
        data = data%>%filter(Treatment== "Cultural Shift" | Treatment== "Population Shift"))
cohensD(trends_closed_demog ~ Treatment, 
        data = data%>%filter(Treatment== "Political Shift" | Treatment== "Population Shift"))

# Politics
SMC_reg2<-lm(trends_closed_pol~ Treatment, data= data)
linearHypothesis(SMC_reg2, "TreatmentCultural Shift=TreatmentPolitical Shift")
linearHypothesis(SMC_reg2, "TreatmentCultural Shift=TreatmentPopulation Shift") 
linearHypothesis(SMC_reg2, "TreatmentPolitical Shift=TreatmentPopulation Shift") 
SMC_reg2<-coeftest(SMC_reg2, vcov= vcovHC, type= "HC1")
SMC_reg2 # print for reported significance tests, full results reported in Appendix C

cohensD(trends_closed_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(trends_closed_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(trends_closed_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))
cohensD(trends_closed_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Cultural Shift" | Treatment== "Political Shift"))
cohensD(trends_closed_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Political Shift" | Treatment== "Population Shift"))

# Media 
SMC_reg3<-lm(trends_closed_media~ Treatment, data= data)
linearHypothesis(SMC_reg3, "TreatmentCultural Shift=TreatmentPolitical Shift")
linearHypothesis(SMC_reg3, "TreatmentCultural Shift=TreatmentPopulation Shift") 
linearHypothesis(SMC_reg3, "TreatmentPolitical Shift=TreatmentPopulation Shift") 
SMC_reg3<-coeftest(SMC_reg3, vcov= vcovHC, type= "HC1") 
SMC_reg3 # print for reported significance tests, full results reported in Appendix C

cohensD(trends_closed_media ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(trends_closed_media ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(trends_closed_media ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))
cohensD(trends_closed_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Cultural Shift" | Treatment== "Political Shift"))
cohensD(trends_closed_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Cultural Shift" | Treatment== "Population Shift"))

### Status Change Regression ###
SC1<-lm(SC_scale~ Treatment, data= data)
linearHypothesis(SC1, "TreatmentCultural Shift=TreatmentPolitical Shift")
linearHypothesis(SC1, "TreatmentCultural Shift=TreatmentPopulation Shift") 
linearHypothesis(SC1, "TreatmentPolitical Shift=TreatmentPopulation Shift") 
SC1<-coeftest(SC1, vcov= vcovHC, type= "HC1")
SC1 # print for reported significance tests, full results reported in Appendix C

cohensD(SC_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(SC_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(SC_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))


### Psychological Mechanism Regressions ###
# symbolic threat
Scale_reg1<-lm(ST_scale~ Treatment, data= data)
Scale_reg1<-coeftest(Scale_reg1, vcov= vcovHC, type= "HC1") 
Scale_reg1 # print for reported significance tests, full results reported in Appendix C

cohensD(ST_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(ST_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(ST_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

# realistic threat
Scale_reg2<-lm(RT_scale~ Treatment, data= data)
Scale_reg2<-coeftest(Scale_reg2, vcov= vcovHC, type= "HC1") 
Scale_reg2 # print for reported significance tests, full results reported in Appendix C

cohensD(RT_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(RT_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(RT_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

# prototypicality threat
Scale_reg3<-lm(PT_scale_full~ Treatment, data= data)
Scale_reg4<-coeftest(Scale_reg3, vcov= vcovHC, type= "HC1") 
Scale_reg4 # print for reported significance tests, full results reported in Appendix C

cohensD(PT_scale_full ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(PT_scale_full ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(PT_scale_full ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))


### Group Attitudes ###
# views of black americans
FT_reg1<-lm(Black_FT~ Treatment, data= data)
FT_reg1<-coeftest(FT_reg1, vcov= vcovHC, type= "HC1")
FT_reg1 # print for reported significance tests, full results reported in Appendix C

cohensD(Black_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(Black_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(Black_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

# views of latino americans
FT_reg2<-lm(Latinos_FT~ Treatment, data= data)
FT_reg2<-coeftest(FT_reg2, vcov= vcovHC, type= "HC1")
FT_reg2 # print for reported significance tests, full results reported in Appendix C

cohensD(Latinos_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(Latinos_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(Latinos_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

# Views of asian americans
FT_reg3<-lm(Asian_FT~ Treatment, data= data)
FT_reg3<-coeftest(FT_reg3, vcov= vcovHC, type= "HC1") 
FT_reg3 # print for reported significance tests, full results reported in Appendix C

cohensD(Asian_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(Asian_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(Asian_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

# views of white americans
FT_reg4<-lm(White_FT~ Treatment, data= data)
FT_reg4<-coeftest(FT_reg4, vcov= vcovHC, type= "HC1") 
FT_reg4 # print for reported significance tests, full results reported in Appendix C

cohensD(White_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(White_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(White_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

# views of blm
FT_reg5<-lm(BLM_FT~ Treatment, data= data)
FT_reg5<-coeftest(FT_reg5, vcov= vcovHC, type= "HC1") 
FT_reg5 # print for reported significance tests, full results reported in Appendix C

cohensD(BLM_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(BLM_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(BLM_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))


# views of the alt right
FT_reg6<-lm(Alt_Right_FT~ Treatment, data= data)
FT_reg6<-coeftest(FT_reg6, vcov= vcovHC, type= "HC1") 
FT_reg6 # print for reported significance tests, full results reported in Appendix C

cohensD(Alt_Right_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(Alt_Right_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(Alt_Right_FT ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

### Policy Positions ###
# racial policy attitudes
Pol_reg1<-lm(racialpolicy_scale~ Treatment, data= data)
Pol_reg1<-coeftest(Pol_reg1, vcov= vcovHC, type= "HC1")
Pol_reg1 # print for reported significance tests, full results reported in Appendix C

cohensD(racialpolicy_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(racialpolicy_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(racialpolicy_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

# non-racial policy attitudes
Pol_reg2<-lm(nonracialpolicy_scale~ Treatment, data= data)
Pol_reg2<-coeftest(Pol_reg2, vcov= vcovHC, type= "HC1")
Pol_reg2 # print for reported significance tests, full results reported in Appendix C

cohensD(nonracialpolicy_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(nonracialpolicy_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))
cohensD(nonracialpolicy_scale ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))

### Participation ###
# political backlash participation
Part_reg1<-lm(backlash_pol~ Treatment, data= data)
Part_reg1<-coeftest(Part_reg1, vcov= vcovHC, type= "HC1")
Part_reg1 # print for reported significance tests, full results reported in Appendix C

cohensD(backlash_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(backlash_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift" ))
cohensD(backlash_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))

# personal backlash participation
Part_reg2<-lm(backlash_person~ Treatment, data= data)
Part_reg2<-coeftest(Part_reg2, vcov= vcovHC, type= "HC1") 
Part_reg2 # print for reported significance tests, full results reported in Appendix C

cohensD(backlash_person ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(backlash_person ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))
cohensD(backlash_person ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))

# political supportive participation
Part_reg3<-lm(support_pol~ Treatment, data= data)
Part_reg3<-coeftest(Part_reg3, vcov= vcovHC, type= "HC1") 
Part_reg3 # print for reported significance tests, full results reported in Appendix C

cohensD(support_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(support_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))
cohensD(support_pol ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Political Shift"))

# personal supportive participation
Part_reg4<-lm(support_person~ Treatment, data= data)
Part_reg4<-coeftest(Part_reg4, vcov= vcovHC, type= "HC1") 
Part_reg4 # print for reported significance tests, full results reported in Appendix C

cohensD(support_person ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Population Shift"))
cohensD(support_person ~ Treatment, 
        data = data%>%filter(Treatment== "Control" | Treatment== "Cultural Shift"))
cohensD(support_person ~ Treatment, 
        data = data%>%filter(Treatment== "Control"| Treatment== "Political Shift"))

#### Exporting Graphs ####

### Figure 1 ###
ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=SC_scale, fill= Treatment)) + 
  ggdist::stat_halfeye(adjust = .5, width = .3, .width = 0, justification = -.3, point_colour = NA) + 
  geom_boxplot(width = .1, outlier.shape = NA) +
  gghalves::geom_half_point(side = "l", range_scale = .4, alpha = .5)+
  scale_fill_brewer(palette = "Dark2")+ ylim(0, 1.4)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(1.1, 1.2, 1.3), textsize = 8, size=1)+ 
  labs(y= "Whites Status Change")+ theme(legend.position = "none")+ Nicole_theme

### Figure 2 ###
ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=ST_scale, fill= Treatment)) + 
  ggdist::stat_halfeye(adjust = .5, width = .3, .width = 0, justification = -.3, point_colour = NA) + 
  geom_boxplot(width = .1, outlier.shape = NA) +
  gghalves::geom_half_point(side = "l", range_scale = .4, alpha = .5)+
  scale_fill_brewer(palette = "Dark2")+ ylim(0, 1.4)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(1.1, 1.2, 1.3), textsize = 8, size=1)+ 
  labs(y= "Symbolic Threat")+ theme(legend.position = "none")+ Nicole_theme

### Figure 3 ###
ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=RT_scale, fill= Treatment)) + 
  ggdist::stat_halfeye(adjust = .5, width = .3, .width = 0, justification = -.3, point_colour = NA) + 
  geom_boxplot(width = .1, outlier.shape = NA) +
  gghalves::geom_half_point(side = "l", range_scale = .4, alpha = .5)+
  scale_fill_brewer(palette = "Dark2")+ ylim(0, 1.4)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE,  y_position = c(1.1, 1.2, 1.3), textsize = 8, size=1)+ 
  labs(y= "Realistic Threat")+ theme(legend.position = "none")+ Nicole_theme

### Figure 4 ###
ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=PT_scale_full, fill= Treatment)) + 
  ggdist::stat_halfeye(adjust = .5, width = .3, .width = 0, justification = -.3, point_colour = NA) + 
  geom_boxplot(width = .1, outlier.shape = NA) +
  gghalves::geom_half_point(side = "l", range_scale = .4, alpha = .5)+
  scale_fill_brewer(palette = "Dark2")+ ylim(0, 1.4)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(1.1, 1.2, 1.3), textsize = 8, size=1)+ 
  labs(y= "Prototypicality Threat")+ theme(legend.position = "none")+ Nicole_theme

### Figure 5 ###
blacks<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=Black_FT)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Black People")+ theme(legend.position = "none")+ ylim(0, 1.1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.75, 0.85, 0.95), textsize = 8, size=1)+ 
  Nicole_theme

latinos<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=Latinos_FT)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Latino People")+ theme(legend.position = "none")+ ylim(0, 1.1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.75, 0.85, 0.95), textsize = 8, size=1)+ 
  Nicole_theme

asians<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=Asian_FT)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Asian People")+ theme(legend.position = "none")+ ylim(0, 1.1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.75, 0.85, 0.95), textsize = 8, size=1)+ 
  Nicole_theme

whites<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=White_FT)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "White People")+ theme(legend.position = "none")+ ylim(0, 1.1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.8, 0.9, 1), textsize = 8, size=1)+ 
  Nicole_theme

blm<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=BLM_FT)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "BLM")+ theme(legend.position = "none")+ ylim(0, 1.1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.5, 0.6, 0.7), textsize = 8, size=1)+ 
  Nicole_theme

alt_right<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=Alt_Right_FT)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+ 
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Alt Right")+ theme(legend.position = "none")+ ylim(0, 1.1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.4, 0.5, 0.6), textsize = 8, size=1)+ 
  Nicole_theme

gridExtra::grid.arrange(blacks, latinos, asians, whites, alt_right, blm, ncol= 3)


### Figure 6 ###
RP<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=racialpolicy_scale, fill= Treatment)) + 
  ggdist::stat_halfeye(adjust = .5, width = .3, .width = 0, justification = -.3, point_colour = NA) + 
  geom_boxplot(width = .1, outlier.shape = NA) +
  gghalves::geom_half_point(side = "l", range_scale = .4, alpha = .5)+
  scale_fill_brewer(palette = "Dark2")+ ylim(0, 1.4)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE,  y_position = c(1.1, 1.2, 1.3), textsize = 8, size=1)+ 
  labs(y= "Conservative Policy Support", title= "Racial Policies")+ theme(legend.position = "none")+ Nicole_theme

NRP<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=nonracialpolicy_scale, fill= Treatment)) + 
  ggdist::stat_halfeye(adjust = .5, width = .3, .width = 0, justification = -.3, point_colour = NA) + 
  geom_boxplot(width = .1, outlier.shape = NA) +
  gghalves::geom_half_point(side = "l", range_scale = .4, alpha = .5)+
  scale_fill_brewer(palette = "Dark2")+ ylim(0, 1.4)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE,  y_position = c(1.1, 1.2, 1.3), textsize = 8, size=1)+ 
  labs(y= "Conservative Policy Support", title= "Nonracial Policies")+ theme(legend.position = "none")+ Nicole_theme

gridExtra::grid.arrange(RP, NRP, ncol= 1)

### Figure 7 ###
pol_backlash<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=backlash_pol)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+ 
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Action Likelihood", title= "Backlash: Political")+ theme(legend.position = "none")+ ylim(0, 1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              annotation = formatC(c("NS.  ", "p= 0.07", "p= 0.07")),
              map_signif_level = TRUE, y_position = c(0.4, 0.55, 0.7), textsize = 8, size=1)+ 
  Nicole_theme

personal_support<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=support_person)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+ 
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Action Likelihood", title= "Support: Personal")+ theme(legend.position = "none")+ ylim(0, 1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.4, 0.55, 0.7), textsize = 8, size=1)+ 
  Nicole_theme

pol_support<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=support_pol)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+ 
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Action Likelihood", title= "Support: Political")+ theme(legend.position = "none")+ ylim(0, 1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              map_signif_level = TRUE, y_position = c(0.55, 0.7, 0.85), textsize = 8, size=1)+ 
  Nicole_theme

personal_backlash<-ggplot(data%>%filter(is.na(Treatment)==F), aes(x=Treatment, y=backlash_person)) + 
  geom_bar(aes(fill= Treatment), position = "dodge", stat = "summary", fun.y = "mean")+
  geom_errorbar(stat='summary', width=.2)+
  scale_fill_brewer(palette = "Dark2")+ 
  scale_x_discrete(guide = guide_axis(n.dodge = 2))+
  labs(y= "Action Likelihood", title= "Backlash: Personal")+ theme(legend.position = "none")+ ylim(0, 1)+
  geom_signif(comparisons = list(c("Control", "Cultural Shift"), c("Control", "Political Shift"), c("Control", "Population Shift")), 
              annotation = formatC(c("NS.  ", "NS.  ", "p= 0.10")),
              map_signif_level = TRUE, y_position = c(0.4, 0.55, 0.7), textsize = 8, size=1)+ 
  Nicole_theme

gridExtra::grid.arrange(personal_support, pol_support, personal_backlash, pol_backlash, ncol= 2)


#### Exporting  Regressions  ####

### Table C1 ###
stargazer(SMC_reg1, SMC_reg2, SMC_reg3,
          align= T,
          column.labels = c("Whites Demographic Minority", "Whites Political Minority", "Whites Cultural Minority"),
          covariate.labels = c ("Cultural Shift Treatment", "Political Shift Treatment", 
                                "Population Treatment"),
          star.cutoffs = c(0.05, 0.01, 0.001))

### Table C2 ###
stargazer(SC1,
          align= T,
          dep.var.labels = c("Status Change"),
          covariate.labels = c ("Cultural Shift Treatment", "Political Shift Treatment", 
                                "Population Treatment"),
          star.cutoffs = c(0.05, 0.01, 0.001))

### Table C3 ###
stargazer(Scale_reg1, Scale_reg2, Scale_reg3,
          align= T,
          column.labels = c("Symbolic Threat", "Realistic Threat", "Prototypicality Threat"),
          covariate.labels = c ("Cultural Shift Treatment", "Political Shift Treatment", 
                                "Population Treatment"),
          star.cutoffs = c(0.05, 0.01, 0.001))

### Table C4 ###
stargazer(FT_reg1, FT_reg2, FT_reg3, FT_reg5,
          align= T,
          column.labels = c("Black FT", "Latino FT", "Asian FT", "BLM FT"),
          covariate.labels = c ("Cultural Shift Treatment", "Political Shift Treatment", 
                                "Population Treatment"),
          star.cutoffs = c(0.05, 0.01, 0.001))

### Table C5 ###
stargazer(FT_reg4, FT_reg6,
          align= T,
          column.labels = c("White FT", "Alt Right FT"),
          covariate.labels = c ("Cultural Shift Treatment", "Political Shift Treatment", 
                                "Population Treatment"),
          star.cutoffs = c(0.05, 0.01, 0.001))

### Table C6 ###
stargazer(Pol_reg1, Pol_reg2,
          align= T,
          column.labels = c("Racial Policy Scale", "Nonracial Policy Scale"),
          covariate.labels = c ("Cultural Shift Treatment", "Political Shift Treatment", 
                                "Population Treatment"),
          star.cutoffs = c(0.05, 0.01, 0.001))

### Table C7 ###
stargazer(Part_reg1, Part_reg2, Part_reg3, Part_reg4,
          align= T,
          column.labels = c("Political Backlash", "Personal Backlash",
                            "Political Supportive", "Personal Supportive"),
          covariate.labels = c ("Cultural Shift Treatment", "Political Shift Treatment", 
                                "Population Treatment"),
          star.cutoffs = c(0.05, 0.01, 0.001))
